<template>
	<view class="conter">
		<header-box :title="title"></header-box>
		<view class="text-tab">
			<view class="box" v-for="(item, index) in textList" :key="index" >
				<view class="box-title" >
					<view class="" style="display: flex;">
						<view class="">
							{{item.company}}
						</view>
						<view class="" v-if="item.currentStatus == 1" style="margin-left: 10rpx; color:#EA2222;font-size: 22rpx;font-weight: 400;">
							未归还
						</view>
						<view class="" v-else style="margin-left: 10rpx; color: #7278EC;font-size: 22rpx;font-weight: 400;">
							待归还 
						</view>
					</view>
					<view class="" style="color: #333333;font-weight: 400;font-size: 26rpx;">
						{{item.store}}
					</view>
				</view>
				<view class="" style="font-weight: 300; font-size: 24rpx;">
					{{item.backtime}}
				</view>
				<view class="flex-box" style="height: 50rpx; line-height: 50rpx;" @tap="clickInfo(item.id)">
					<view class="">
						备注：{{item.memo}}
					</view>
					<view class="" style="color: #7278EC;">
						查看商品>>
					</view>
				</view>

			</view>
		</view>




		<u-popup v-model="popupShow" mode="center" width="70%" height="280rpx" border-radius="10">
			<view class="show" style="margin-top: 30rpx;">
				提示
			</view>
			<view class="show" style="font-size: 28rpx; color: #999999;">
				确定要归还吗？
			</view>
			<view class="show flex-around add-class">
				<view class="" @click="popupShow = false" style="background-color: #CCCCCC; color: #FFFFFF;">
					取消
				</view>
				<view class="bg-gradual-green" @click="returnStoack">
					确定
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'

	export default {
		components: {
			headerBox
		},
		data() {
			return {
				title: '单子列表',
				textList: [],
				addUrl: '',
				redactShow: false,
				list: [{
					name: '编辑',
					show: true
				}, {
					name: '删除',
					show: true
				}, {
					name: '取消',
					show: false
				}],
				tabText: 0,
				popupShow: false,
				stock: '1',
				stockId: '',
			}
		},
		onLoad(e) {
			this.time1 = Date.parse(new Date()) / 1000;
			console.log('本地', this.time1)
		},
		onShow() {
			this.getList()

		},
		methods: {
			
			clickInfo(id) {
				uni.navigateTo({
					url: '/pages/removeStock/listInfo?id=' + id
				})
			},

			// 获取;列表 
			async getList() {
				const res = await this.$u.post("api/jinxiao.Enter/revert", {});
				console.log('获取;列表', res)
				this.textList = res.data
				this.dataTime()
			},


			textTile(e) {

			},

			// 归还仓库
			async returnStoack() {
				const res = await this.$u.post("api/jinxiao.Enter/add", {
					back_store_id: this.stockId
				});
				this.getList()
				this.$tools.msg(res.msg)
				this.popupShow = false
				console.log(res)
				
			},


			dataTime() {
				this.textList.forEach(i => {
					// 1、带归还 现在的时间比归还的时间大 2、未归还
					i.currentStatus = 1
					
					if (this.time1 < i.backtime) {
						i.currentStatus = 2
					} else if (this.time1 > i.backtime) {
						i.currentStatus = 1
					} 
				})
			},

			skip(item) {	
				this.stockId = item.id
			},

			elect(item, index) {
				console.log(index)
				this.tabText = index
				this.redactShow = item.show
				if (index == 0) {
					uni.navigateTo({
						url: '/pages/shopping/compile'
					})
					// 跳转到编辑页面
					// this.redactShow = true
				} else if (index == 1) {
					// 调用删除事件
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100vh;
		font-size: 24rpx;
		position: relative;
		background-color: #EEEEEE;

		image {
			width: 100%;
			height: 100%;
		}

		.text-tab {
			width: 100%;
			padding: 30rpx;
			padding-bottom: 0;
			// background-color: #FFFFFF;

			.box-width {
				color: #333333;
				width: 70% !important;
				margin-bottom: 30rpx;

				view {
					padding: 13rpx 23rpx;
					background: #EBEBF0;
					border-radius: 4rpx;
				}
			}

			.box {
				width: 100%;
				color: #666666;
				padding: 30rpx 30rpx 0;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				margin-bottom: 30rpx;

				.box-title {
					font-size: 28rpx;
					font-weight: bold;
					height: 60rpx;
					color: #000000;
					display: flex;
					justify-content: space-between;
					font-family: PingFang SC;
					line-height: 60rpx;
				}

				.box-data {
					height: 60rpx;
					line-height: 60rpx;
				}

				.bot-bor {
					height: 88rpx;
					line-height: 88rpx;
					// background-color: red;
					margin-top: 20rpx;
					// padding-top: 20rpx;
					border-top: 1rpx solid #EEEEEE;
					// float: right;
				}
			}

			.marg-box {
				width: 100%;
				height: 75rpx;
				line-height: 75rpx;
				display: flex;
				margin: 0 auto;
				text-align: center;
				text-align: center;
				justify-content: space-around;
			}

			.box-border {
				width: 90%;
				height: 75rpx;
				line-height: 75rpx;
				color: #333333;
				margin: 0 auto;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				border-top: 1rpx solid #F0F0F0;
			}

			.box-width {
				width: 90%;
			}

			.marige-bor {
				width: 100%;
				margin: 0 auto;
				color: #333333;
				display: flex;
				font-size: 28rpx;
				align-items: center;
				background-color: #FFFFFF;
				border-top: 1rpx solid #F0F0F0;
				justify-content: space-between;

				.diso-flex {
					width: 90%;
					height: 80rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
				}

				.conter-image {
					width: 22rpx;
					height: 36rpx;
					font-weight: 700;
					color: #999;
				}
			}

			.marige-bor:last-child {
				border-bottom: 0;
			}
		}

		.total {
			width: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			height: 100rpx;
			padding: 0 60rpx 0 30rpx;
			background-color: #FFFFFF;
		}



		.botm-flix {
			position: absolute;
			bottom: 44rpx;
			left: 0;
			width: 100%;
			height: 90rpx;
			display: flex;
			font-size: 32rpx;
			align-items: center;
			padding: 0 30rpx;

			view {
				width: 100%;
				height: 90rpx;
				text-align: center;
				line-height: 90rpx;
				border-radius: 45rpx;
				margin: 0 auto;
			}
		}



	}

	.padd-text {
		width: 80%;
		height: 106rpx;
		line-height: 106rpx;
		text-align: center;
		font-size: 28rpx;
		color: #333;
		border-bottom: 1rpx solid #EEEEEE;
		margin: 0 auto;
	}

	.color-text {
		color: #7278EC;
	}

	.none-color {
		color: #000;
	}

	.input-text {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		margin-top: 10rpx;
	}

	.input-val {
		width: 80%;
		height: 78rpx;
		margin: 0 auto;
	}

	.text-select {
		width: 90%;
		margin: 0 auto;
		border-top: 1rpx solid #F0F0F0;
		display: flex;
		// padding-top: 20rpx;
		justify-content: space-around;

		view {
			width: 50%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-right: 1rpx solid #F0F0F0;
		}

		view:last-child {
			border-right: 0;
		}
	}


	.box1 {
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 0 30rpx;

		.box-bgc {
			width: 330rpx;
			height: 60rpx;
			text-align: center;
			line-height: 60rpx;
			border-radius: 6rpx;
			background-color: #F2F3F7;
		}
	}


	.cen {

		.padding-eft {
			width: 90%;
			height: 76rpx;
			margin: 0 auto;
			line-height: 76rpx;
			padding-left: 0;
			border-bottom: 1rpx solid #F5F5F5;

			view {
				width: 100%;
			}
		}

		.padding-eft:last-child {
			border-bottom: 0;
		}
	}




	.add-class {
		width: 100%;
		height: 70rpx;

		view {
			width: 30%;
			height: 70rpx;
			line-height: 70rpx;
			text-align: center;
			font-size: 30rpx;
			font-family: PingFang SC;
			border-radius: 35rpx;
		}
	}
</style>
